﻿using System;

namespace UniRx.Operators
{
	// Token: 0x020002A0 RID: 672
	internal class EmptyObservable<T> : OperatorObservableBase<T>
	{
		// Token: 0x06000ECC RID: 3788 RVA: 0x00045561 File Offset: 0x00043961
		public EmptyObservable(IScheduler scheduler) : base(false)
		{
			this.scheduler = scheduler;
		}

		// Token: 0x06000ECD RID: 3789 RVA: 0x00045571 File Offset: 0x00043971
		protected override IDisposable SubscribeCore(IObserver<T> observer, IDisposable cancel)
		{
			observer = new EmptyObservable<T>.Empty(observer, cancel);
			if (this.scheduler == Scheduler.Immediate)
			{
				observer.OnCompleted();
				return Disposable.Empty;
			}
			return this.scheduler.Schedule(new Action(observer.OnCompleted));
		}

		// Token: 0x04000893 RID: 2195
		private readonly IScheduler scheduler;

		// Token: 0x020002A1 RID: 673
		private class Empty : OperatorObserverBase<T, T>
		{
			// Token: 0x06000ECE RID: 3790 RVA: 0x000455B0 File Offset: 0x000439B0
			public Empty(IObserver<T> observer, IDisposable cancel) : base(observer, cancel)
			{
			}

			// Token: 0x06000ECF RID: 3791 RVA: 0x000455BC File Offset: 0x000439BC
			public override void OnNext(T value)
			{
				try
				{
					this.observer.OnNext(value);
				}
				catch
				{
					base.Dispose();
					throw;
				}
			}

			// Token: 0x06000ED0 RID: 3792 RVA: 0x000455F8 File Offset: 0x000439F8
			public override void OnError(Exception error)
			{
				try
				{
					this.observer.OnError(error);
				}
				finally
				{
					base.Dispose();
				}
			}

			// Token: 0x06000ED1 RID: 3793 RVA: 0x00045630 File Offset: 0x00043A30
			public override void OnCompleted()
			{
				try
				{
					this.observer.OnCompleted();
				}
				finally
				{
					base.Dispose();
				}
			}
		}
	}
}
